home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: news.ner.bbnplanet.net!daprez!panther!otisg
- From: otisg@panther.middlebury.edu (Otis Gospodnetic)
- Subject: Process Scheduling (Mult. Feedback Queues) question
- Message-ID: <357cc$12f26.1a1@daprez>
- Date: Tue, 05 Mar 1996 06:47:37 GMT
- X-Newsreader: TIN [version 1.2 PL2]
-
-
- Hello,
-
- a friend and I need some help with our Process Scheduling simulation, that
- we are trying to implement in C++....fun....
- We need to simulate multiple feedback queues.
- So, we said, we'll make each process (hereafter called a job) a struct, that
- will have some data and a pointer to the next struct of the same kind....
- So we did something like this:
-
- typedef struct JobStruct {
- // a bunch of struct members here, the data stuff
- struct JobStruct *next; // Pointer to the next Job in the Queue
- } Job;
-
-
- that looks okay so far, right ?
- then since we need to have multiple queues we decided that queues should have
- some data (like quantum, priority/level) and then a pointer to the next queue
- level (1->2->3....) and a pointer to the first Job in that queue.
- So we tried declaring it as follows (again some struct):
-
- typedef struct QueueStruct {
- int Quantum; // Quantum for Level
- int Level; // Priority
-
- // Now I am really not sure we declared this pointer to the first job in the
- // queue right here... comments ?
- Job *JobStruct; // Ptr to the First Job in Queue
- struct QueueStruct *next; // Ptr to the Next Queue
- } Queue;
-
- that pointer to a Job struct looks weird to me....
- what should it be, if the above is incorrect ? Gotta love those pointers....
-
- Also, would some different ADTs b better for doing this ?
- A Stack for Queues instead of a struct with pointers ?
-
- Thanks !
-
- Otis
- P.S.
- this is how we "imagine" the whole thing:
-
- Q1 -> J1 -> J2 -> J3 -> ..... -> NULL
- |
- V
- Q2 -> J1 -> J2 -> J3 -> ..... -> NULL
- |
- V
- Q3 -> J1 -> J2 -> J3 -> ..... -> NULL
- |
- V
- .
- .
- |
- V
- NULL
-
- --
- Otis.Gospodnetic@mail.middlebury.edu
- Information Technology Services
- Middlebury College
-
-